<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :list="swiperList"></home-swiper>
    <home-icons :list="iconList"></home-icons>
    <home-sale :list="saleList"></home-sale>
    <home-ticket></home-ticket>
    <home-footer></home-footer>
  </div>
</template>

<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeSale from './components/Sale'
import HomeTicket from './components/Ticket'
import HomeFooter from './components/Footer'
/* 引入axios */
import axios from 'axios'
export default {
  name: 'Home',
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeSale,
    HomeTicket,
    HomeFooter
  },
  mounted () {
    this.getCityInfo()
  },
  data () {
    return {
      city: '',
      swiperList: [],
      iconList: [],
      saleList: []
    }
  },
  methods: {
    getCityInfo: function () {
      axios.get('/api/index.json')
        .then(this.getCityInfoSucc)
    },
    /* res代表response */
    getCityInfoSucc: function (res) {
      res = res.data
      console.log(res)
      if (res.ret && res.data) {
        this.city = res.data.city
        this.swiperList = res.data.swiperList
        this.iconList = res.data.iconList
        this.saleList = res.data.saleList
      }
    }
  }
}
</script>

<style scoped>

</style>
